export default {
  name: 'tooltip',
  bind(el, binding) {
    el.style.position = 'relative';
    const tip = document.createElement('span');
    if (binding.modifiers.top) {
      tip.className = 'tip-top';
      tip.innerText = 'tip-top,提示信息';
      el.onmouseenter = function () {
        tip.style.display = 'block';
      };
      el.onmouseout = function () {
        tip.style.display = 'none';
      };
    } else if (binding.modifiers.left) {
      tip.className = 'tip-left';
      tip.innerText = 'tip-left';
      el.onmouseenter = function () {
        tip.style.display = 'block';
      };
      el.onmouseout = function () {
        tip.style.display = 'none';
      };
    } else if (binding.modifiers.right) {
      tip.className = 'tip-right';
      tip.innerText = 'tip-right';
      el.onmouseenter = function () {
        tip.style.display = 'block';
      };
      el.onmouseout = function () {
        tip.style.display = 'none';
      };
    } else if (binding.modifiers.bottom) {
      tip.className = 'tip-bottom';
      tip.innerText = 'tip-bottom';
      el.onmouseenter = function () {
        tip.style.display = 'block';
      };
      el.onmouseout = function () {
        tip.style.display = 'none';
      };
    } else {
      tip.className = 'tip';
    }
    el.appendChild(tip);
  },
};
